package analyticsServer;

import java.util.ArrayList;

/**
 * Class for Events concerning Users (User login, logout or disconnect)
 * 
 * @author Group 95
 */
public class UserEvent extends Event
{
    protected String userName;
    
    public static String USER_LOGIN="USER_LOGIN";
    public static String USER_LOGOUT="USER_LOUGOUT";
    public static String USER_DISCONNECTED="USER_DISCONNECTED";
    
    
    public UserEvent(String server,String type,long timestamp,String userName)
    {
        super(server,type,timestamp);
        this.userName=userName;
    }

    public String getUserName()
    {
        return this.userName;
    }
    
    @Override
    public String toString()
    {
        String strRet=super.toString()+"user "+userName+" ";
        if(type.equals(USER_LOGIN))
        {
            strRet+="logged in";
        }
        else if(type.equals(USER_LOGOUT))
        {
            strRet+="logged out";
        }
        else if(type.equals(USER_DISCONNECTED))
        {
            strRet+="got disconnected";
        }
        return strRet;
    }
    
    
    @Override
    public ArrayList<StatisticsEvent> calculate(EventCalculator calculator)
    {
        return calculator.calculate(this);
    }        
}

